package org.example.springboot.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class TimeAspect {
    @Pointcut(value = "execution(* org.example.springboot.controller.*.*(..))")
    public void aopWebLog() {
    }

    @Around("aopWebLog()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
        log.info("around before...");
        Object result = joinPoint.proceed();
        log.info("around after...");
        return result;
    }

    @After("aopWebLog()")
    public void after(){
        log.info("after...");
    }

    @AfterReturning("aopWebLog()")
    public void afterReturning(){
        log.info("afterReturning...");
    }

    @AfterThrowing("aopWebLog()")
    public void afterThrowing(){
        log.info("afterThrowing...");
    }
}